import request from '@/utils/request'

// Mock数据
const mockSenderList = [
  {
    senderId: 1,
    senderName: '北京发货公司',
    contactPerson: '张经理',
    contactPhone: '13800138001',
    address: '北京市朝阳区建国路88号',
    createTime: '2024-01-10 09:00:00'
  },
  {
    senderId: 2,
    senderName: '广州发货公司',
    contactPerson: '李经理',
    contactPhone: '13800138002',
    address: '广州市天河区珠江新城',
    createTime: '2024-01-12 10:30:00'
  },
  {
    senderId: 3,
    senderName: '深圳发货公司',
    contactPerson: '王经理',
    contactPhone: '13800138003',
    address: '深圳市南山区科技园',
    createTime: '2024-01-14 14:20:00'
  }
]

// 查询发货方列表
export function listSender(query) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '操作成功',
        rows: mockSenderList,
        total: mockSenderList.length
      })
    }, 300)
  })
}

// 查询发货方详细
export function getSender(senderId) {
  return new Promise((resolve) => {
    setTimeout(() => {
      const sender = mockSenderList.find(item => item.senderId == senderId) || mockSenderList[0]
      resolve({
        code: 200,
        msg: '操作成功',
        data: sender
      })
    }, 300)
  })
}

// 新增发货方
export function addSender(data) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '新增成功'
      })
    }, 800)
  })
}

// 修改发货方
export function updateSender(data) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '修改成功'
      })
    }, 800)
  })
}

// 删除发货方
export function delSender(senderId) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '删除成功'
      })
    }, 500)
  })
}

// 导出发货方
export function exportSender(query) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '导出成功'
      })
    }, 1000)
  })
}